#include <iostream>
#include <vector>

using namespace std;
class Solution
{
public:
    /**
     * @brief
     *  int -> 32位
        奇数位全1 -> 0101.... 表示为 0x55555555
        偶数位全1 -> 1010.... 表示为 0xaaaaaaaa
     * @param num
     * @return int
     */
    int exchangeBits(int num)
    {
        return ((num & 0x55555555) << 1) | ((num & 0xaaaaaaaa) >> 1);
    }

    int exchangeBits(int num)
    {
        int even = num & 0b10101010101010101010101010101010; // 0xaaaaaaaa
        int odd = num & 0b01010101010101010101010101010101;  // 0x55555555
        even >>= 1;
        odd <<= 1;
        return even | odd;
    }
};
int main()
{
    Solution s;
    int num = 0b1001101;
    cout << s.exchangeBits(num) << endl;
    return 0;
}